<template>
	<div>
		<el-form ref="form" :model="form" :rules="rules" label-width="80px">
			<el-row>
				<el-col :span="9">
					<el-form-item  label-width="125px" label="档案编号" prop="workerName"><el-input v-model="form.recordId"></el-input></el-form-item>
				</el-col>
				<el-col :span="14">
					<el-form-item label-width="225px" label="姓名" prop="workerGender"><el-input v-model="form.customerName"></el-input></el-form-item>
				</el-col>
			</el-row>

			<el-row>
				<el-col :span="9">
					<el-form-item  label-width="125px" label="客户id" prop="workerAge"><el-input v-model="form.customerId"></el-input></el-form-item>
				</el-col>

				<el-col :span="14">
					<el-form-item label-width="225px" label="性别" prop="staffId"><el-input v-model="form.customerGender"></el-input></el-form-item>
				</el-col>
			</el-row>

			<el-row>
				<el-col :span="8">
					<el-form-item label="床位使用起始日期" prop="entryTime" label-width="125px">
						<el-date-picker value-format="yyyy-MM-dd" type="date" v-model="form.bedSdate" placeholder="选择日期"></el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="15">
					<el-form-item label-width="256px" label="床位使用结束日期" prop="operatorTime">
						<el-date-picker value-format="yyyy-MM-dd" type="date" v-model="form.bedEdate" placeholder="选择日期"></el-date-picker>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="8">
					<el-form-item  label-width="125px" label="床位状态"><el-input v-model="form.bedStatus"></el-input></el-form-item>
				</el-col>
				<el-col :span="15">
					<el-form-item label-width="256px" label="床位详细信息"><el-input v-model="form.bedInfo"></el-input></el-form-item>
				</el-col>
			</el-row>
			<el-form-item><el-button type="primary" plain @click="save">保存数据</el-button></el-form-item>
		</el-form>
	</div>
</template>

<script>
import axios from '@/utils/axiosutils.js';

export default {
	name: 'BedAdd',
	props: ['editid'],
	components: {},
	data() {
		return {
			form: {
				recordId: '',
				customerName: '',
				customerId: '',
				customerGender: '',
				bedStatus: '',
				bedSdate: '',
				bedEdate: '',
				bedInfo: ''
			},
			rules: {
				rule: [{ required: true, message: '请输入', trigger: 'blur' }]
			},
			isupdate: false,
			options: [
				{
					value: '男',
					label: '男'
				},
				{
					value: '女',
					label: '女'
				}
			]
		};
	},
	created() {
		if (this.editid) {
			// 如果是修改 用户名输入框禁用
			this.isupdate = true;
			axios.get(
				'/bed/getById',
				response => {
					this.form.bedId = this.editid;
					this.form.recordId = response.obj.recordId;
					this.form.customerName = response.obj.customerName;
					this.form.customerId = response.obj.customerId;
					this.form.customerGender = response.obj.customerGender;
					this.form.bedStatus = response.obj.bedStatus;
					this.form.bedSdate = response.obj.bedSdate;
					this.form.bedEdate = response.obj.bedEdate;
					this.form.bedInfo = response.obj.bedInfo;
				},
				{
					bedId: this.editid
				}
			);
		}
	},
	methods: {
		save: function() {
			axios.post(
				'/bed/add',
				resp => {
					this.$emit('update:show', false);
					this.$emit('getData');
				},
				this.form
			);
		}
	}
};
</script>

<style scoped>
	.el-row{
		height:60px;
	}
</style>
